//
//  CTCommentHeaderView.m
//  ConstellationTalk_0.1
//
//  Created by riley on 15/6/1.
//  Copyright (c) 2015年 riley chu. All rights reserved.
//

#import "CTCommentHeaderView.h"
#import "CTDebugManager.h"
#import "CTHeader.h"
#import "UIViewAdditions.h"
#import "CTAppLanguage.h"
#import "CTDeviceFunction.h"
#import "CTRequestUtil.h"

@interface CTCommentHeaderView()
{
    UIButton        *headerImageView;
    UIImageView     *sexImageView;
    UILabel         *nameLabel;
    UIImageView     *sqcImageView;
    UILabel         *sqcLabel;
    UILabel         *timeLabel;
    UIButton        *picImageView;
    UILabel         *describeLabel;
    UIButton        *favourBtn;
    UILabel         *favourLabel;
    UILabel         *favCountLabel;
    UIView          *favHeadView;
    UILabel         *bottomLine;
    UILabel         *bottomLabel;
    
    BOOL favBool;
    int favNumber;
    NSMutableArray *favArray;
    
}

@end

@implementation CTCommentHeaderView

@synthesize delegate;

- (void)dealloc
{
    favArray = nil;
    delegate = nil;
    [headerImageView removeFromSuperview];
    headerImageView = nil;
    [sexImageView removeFromSuperview];
    sexImageView = nil;
    [nameLabel removeFromSuperview];
    nameLabel = nil;
    [sqcImageView removeFromSuperview];
    sqcImageView = nil;
    [sqcLabel removeFromSuperview];
    sqcLabel = nil;
    [timeLabel removeFromSuperview];
    timeLabel = nil;
    [picImageView removeFromSuperview];
    picImageView = nil;
    [describeLabel removeFromSuperview];
    describeLabel = nil;
    [favourBtn removeFromSuperview];
    favourBtn = nil;
    [favourLabel removeFromSuperview];
    favourLabel = nil;
    [favCountLabel removeFromSuperview];
    favCountLabel = nil;
    [favHeadView removeFromSuperview];
    favHeadView =nil;
    [bottomLine removeFromSuperview];
    bottomLine = nil;
    [bottomLabel removeFromSuperview];
    bottomLabel = nil;
    [favHeadView removeFromSuperview];
    favHeadView = nil;
    [CTDebugManager showDebugLogInfo:@"dealloc : CTCommentHeaderView Is Removed!!!"];
}
- (instancetype)init
{
    self = [super init];
    if (self) {
        self.frame = CGRectMake(0, 64, CT_HEADER_SCREEN_WIDTH, 625);
        [self createHeadView];
    }
    return self;
}

- (void)createHeadView
{
    //头像
    headerImageView = [UIButton buttonWithType:UIButtonTypeCustom];
    headerImageView.frame = CGRectMake(10, 15, 45, 45);
    [headerImageView setBackgroundImage:[UIImage imageNamed:@"head"] forState:UIControlStateNormal];
    [headerImageView addTarget:self action:@selector(headImageBtnAction:) forControlEvents:UIControlEventTouchUpInside];
    headerImageView.layer.masksToBounds = YES;
    headerImageView.layer.cornerRadius  = 22.5;
    [self addSubview:headerImageView];
    //性别
    sexImageView = [[UIImageView alloc]initWithFrame:CGRectMake(40,headerImageView.origin.y+30, 21, 21)];
    sexImageView.image = [UIImage imageNamed:@"female"];//男 male
    [self addSubview:sexImageView];
    //名字
    nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(headerImageView.right+10, 25, CT_HEADER_SCREEN_WIDTH-65-70, 18)];
    nameLabel.font =[UIFont systemFontOfSize:18.0f];
    nameLabel.textAlignment = NSTextAlignmentLeft;
    nameLabel.textColor = CT_HEADER_BLACK_COLOR;
    nameLabel.backgroundColor = [UIColor redColor];
    [self addSubview:nameLabel];
    //关注按钮
    
    //认证画师
    sqcImageView = [[UIImageView alloc]initWithFrame:CGRectMake(headerImageView.right+10, nameLabel.bottom+5, 13, 13)];
    sqcImageView.image = [UIImage imageNamed:@"v"];
    [self addSubview:sqcImageView];
    
    //认证画师Label
    sqcLabel = [[UILabel alloc]initWithFrame:CGRectMake(sqcImageView.right+5, nameLabel.bottom+8, CT_HEADER_SCREEN_WIDTH-65-70-30, 10)];
    sqcLabel.font =[UIFont systemFontOfSize:10.0f];
    sqcLabel.textAlignment = NSTextAlignmentLeft;
    sqcLabel.text = [CTAppLanguage localizedStringForKey:@"userView_label_vipLabel" withValue:nil withTable:@"Language"];
    sqcLabel.textColor = [UIColor colorWithRed:164/255.0 green:164/255.0 blue:164/255.0 alpha:1.0];
    sqcLabel.backgroundColor = [UIColor clearColor];
    [self addSubview:sqcLabel];
    
    
    //时间
    timeLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 57, CT_HEADER_SCREEN_WIDTH-20, 12)];
    timeLabel.font =[UIFont systemFontOfSize:12.0f];
    timeLabel.textAlignment = NSTextAlignmentRight;
    timeLabel.textColor = [UIColor colorWithRed:164/255.0 green:164/255.0 blue:164/255.0 alpha:1.0];
    timeLabel.backgroundColor = [UIColor clearColor];
    timeLabel.text = @"1分钟前";
    [self addSubview:timeLabel];
    //大图
    picImageView = [UIButton buttonWithType:UIButtonTypeCustom];
    picImageView.frame = CGRectMake(0, headerImageView.bottom+13, CT_HEADER_SCREEN_WIDTH, CT_HEADER_SCREEN_WIDTH);
    picImageView.backgroundColor = [UIColor clearColor];
    [picImageView addTarget:self action:@selector(picImageBtnAction:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:picImageView];
    
    //描述
    describeLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, picImageView.bottom+7.5, CT_HEADER_SCREEN_WIDTH-20, 40)];
    describeLabel.font = [UIFont systemFontOfSize:15.0f];
    describeLabel.backgroundColor = [UIColor clearColor];
    describeLabel.textColor =[UIColor colorWithRed:164/255.0 green:164/255.0 blue:164/255.0 alpha:1.0];
    describeLabel.textAlignment = NSTextAlignmentLeft;
    describeLabel.numberOfLines = 2;
    describeLabel.lineBreakMode = NSLineBreakByCharWrapping;
    NSMutableAttributedString *AttributedStr = [[NSMutableAttributedString alloc]initWithString:@"#今天#天气不错呀不错呀不错呀不错呀不错呀不错呀不错呀不错呀不错呀不错呀不错呀不错呀不错呀不错呀不错呀不错呀不错呀不错呀不错呀不错呀"];
    
    [AttributedStr addAttribute:NSFontAttributeName
     
                          value:[UIFont systemFontOfSize:15.0]
     
                          range:NSMakeRange(0, 4)];
    //     [AttributedStr addAttribute:NSLinkAttributeName value:aURL range:range];
    [AttributedStr addAttribute:NSForegroundColorAttributeName
     
                          value:[UIColor colorWithRed:255/255.0 green:134/255.0 blue:49/255.0 alpha:1.0]
     //    从第N个起 的几个字
                          range:NSMakeRange(0, 4)];
    
    describeLabel.attributedText = AttributedStr;
    [self addSubview:describeLabel];
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = describeLabel.frame;
    //    button.frame = CGRectMake(0, 0, desRange.length*15, 20);
    //        button.backgroundColor = [UIColor redColor];
    [button addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:button];
    //点赞
    favourBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    favourBtn.frame = CGRectMake(20, describeLabel.bottom+20, 25, 25);
    [favourBtn setBackgroundImage:[UIImage imageNamed:@"dianzan"] forState:UIControlStateNormal];
    [favourBtn addTarget:self action:@selector(favourBtnAction:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:favourBtn];
    favourLabel = [[UILabel alloc]initWithFrame:CGRectMake(favourBtn.right+10, describeLabel.bottom+25, 30, 15)];
    favourLabel.font =[UIFont systemFontOfSize:15.0f];
    favourLabel.textAlignment = NSTextAlignmentLeft;
    favourLabel.text = [CTAppLanguage localizedStringForKey:@"fllow_favourLabel_title" withValue:nil withTable:@"Language"];
    favourLabel.textColor = CT_HEADER_BLACK_COLOR;
    favourLabel.backgroundColor = [UIColor clearColor];
    [self addSubview:favourLabel];

    //评论
    UIButton * commentBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    commentBtn.frame = CGRectMake(favourLabel.right+20, describeLabel.bottom+20, 25, 25);
    [commentBtn setBackgroundImage:[UIImage imageNamed:@"pinglun"] forState:UIControlStateNormal];
    [commentBtn addTarget:self action:@selector(commentBtnAction:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:commentBtn];
    UILabel * commentLabel = [[UILabel alloc]initWithFrame:CGRectMake(commentBtn.right+10, describeLabel.bottom+25, 30, 15)];
    commentLabel.font =[UIFont systemFontOfSize:15.0f];
    commentLabel.textAlignment = NSTextAlignmentLeft;
    commentLabel.text = [CTAppLanguage localizedStringForKey:@"fllow_commentLabel_title" withValue:nil withTable:@"Language"];
    commentLabel.textColor = CT_HEADER_BLACK_COLOR;
    commentLabel.backgroundColor = [UIColor clearColor];
    [self addSubview:commentLabel];
    
    //分享
    UIButton * shareBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    shareBtn.frame = CGRectMake(commentLabel.right+20, describeLabel.bottom+20, 25, 25);
    [shareBtn setBackgroundImage:[UIImage imageNamed:@"share"] forState:UIControlStateNormal];
    [shareBtn addTarget:self action:@selector(shareBtnAction:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:shareBtn];
    UILabel * shareLabel = [[UILabel alloc]initWithFrame:CGRectMake(shareBtn.right+10, describeLabel.bottom+25, 30, 15)];
    shareLabel.font =[UIFont systemFontOfSize:15.0f];
    shareLabel.textAlignment = NSTextAlignmentLeft;
    shareLabel.text = [CTAppLanguage localizedStringForKey:@"fllow_shareLabel_title" withValue:nil withTable:@"Language"];
    shareLabel.textColor = CT_HEADER_BLACK_COLOR;
    shareLabel.backgroundColor = [UIColor clearColor];
    [self addSubview:shareLabel];
    
    UIButton * moreBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    moreBtn.frame = CGRectMake(CT_HEADER_SCREEN_WIDTH-25-20, describeLabel.bottom+20, 25, 25);
    [moreBtn setBackgroundImage:[UIImage imageNamed:@"more"] forState:UIControlStateNormal];
    [moreBtn addTarget:self action:@selector(moreBtnAction:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:moreBtn];
    
    UIImageView *favImageView = [[UIImageView alloc]initWithFrame:CGRectMake(10, favourBtn.bottom+32, 15, 15)];
    favImageView.image = [UIImage imageNamed:@"dianzanrenshu"];
    [self addSubview:favImageView];
    
    favCountLabel = [[UILabel alloc]initWithFrame:CGRectMake(favImageView.right+5, favourBtn.bottom+34, 50, 15)];
    favCountLabel.font =[UIFont systemFontOfSize:15.0f];
    favCountLabel.textAlignment = NSTextAlignmentLeft;
    favCountLabel.text = @"999W";
    //    commentLabel.text = [CTAppLanguage localizedStringForKey:@"fllow_commentLabel_title" withValue:nil withTable:@"Language"];
    favCountLabel.textColor = [UIColor colorWithRed:164/255.0 green:164/255.0 blue:164/255.0 alpha:1.0];
    //    favCountLabel.backgroundColor = [UIColor redColor];
    [self addSubview:favCountLabel];
    
    bottomLine = [[UILabel alloc]initWithFrame:CGRectMake(0, self.height-30.5, CT_HEADER_SCREEN_WIDTH, 0.5)];
    bottomLine.backgroundColor = CT_HEADER_BRIGHTLINE_COLOR;
    [self addSubview:bottomLine];
    
    bottomLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, self.height-30, CT_HEADER_SCREEN_WIDTH, 30)];
    bottomLabel.backgroundColor = [UIColor colorWithRed:250/255.0 green:250/255.0 blue:240/255.0 alpha:1.0];
    [self addSubview:bottomLabel];


}
- (void)createFavHeadImageView:(NSMutableArray *) ary
{
    [favHeadView removeFromSuperview];
    
    favHeadView = [[UIView alloc]initWithFrame:CGRectMake(favCountLabel.right+10, favourBtn.bottom+25, CT_HEADER_SCREEN_WIDTH-110, 30)];
    [self addSubview:favHeadView];
    DeviceTypeAdaptation  devictType = [CTDeviceFunction deviceTypeForResolutionAdaptation];
    if (devictType == iPhone5_5s_5c ||devictType == iPhone4_4s)
    {
        int count = 0;
        if (ary.count >=6)
        {
            count = 6;
        }
        float  jianju =(CT_HEADER_SCREEN_WIDTH-110-180)/5;
        for (int i = 0; i < count; i++)
        {
            FavHeadBtn * favBtn = [FavHeadBtn buttonWithType:UIButtonTypeCustom];
            [favBtn addTarget:self action:@selector(imageViewBtnAction:) forControlEvents:UIControlEventTouchUpInside];
            favBtn.frame = CGRectMake(i*30+i*jianju,0,30,30);
            favBtn.layer.masksToBounds = YES;
            favBtn.layer.cornerRadius  = 15;
            favBtn.tag = 1000+i;
            favBtn.imgUrl = [ary objectAtIndex:i];
            [favHeadView addSubview:favBtn];
        }
        
    }
    else
    {
        int count = 0;
        if (ary.count >=8)
        {
            count = 8;
        }
        float  jianju =(CT_HEADER_SCREEN_WIDTH-110-240)/7;
        for (int i = 0; i < count; i++)
        {
            FavHeadBtn * favBtn = [FavHeadBtn buttonWithType:UIButtonTypeCustom];
            [favBtn addTarget:self action:@selector(imageViewBtnAction:) forControlEvents:UIControlEventTouchUpInside];
            favBtn.frame = CGRectMake(i*30+i*jianju,0,30,30);
            favBtn.layer.masksToBounds = YES;
            favBtn.layer.cornerRadius  = 15;
            favBtn.tag = 1000+i;
            favBtn.imgUrl = [ary objectAtIndex:i];
            [favHeadView addSubview:favBtn];
        }
        
    }
    
}

//点击头像
- (void)headImageBtnAction:(UIButton *) sender
{
    if ([self.delegate respondsToSelector:@selector(userPublishTableCellHitHeadAction:withID:)])
    {
        [self.delegate userPublishTableCellHitHeadAction:self withID:nil];
    }

}
//点击大图
- (void)picImageBtnAction:(UIButton *) sender
{
    if ([self.delegate respondsToSelector:@selector(userPublishTableCellHitPicImageBtnAction:withID:)])
    {
        [self.delegate userPublishTableCellHitPicImageBtnAction:self withID:nil];
    }

}
//点击话题
- (void)buttonAction:(UIButton *) sender
{
    if ([self.delegate respondsToSelector:@selector(userPublishTableCellHitTopicBtnAction:withID:)])
    {
        [self.delegate userPublishTableCellHitTopicBtnAction:self withID:nil];
    }
}
//点赞
- (void)favourBtnAction:(UIButton *) sender
{
    //需要什么返回值
    if (favBool)
    {
        [favourBtn setBackgroundImage:[UIImage imageNamed:@"dianzan"] forState:UIControlStateNormal];
        favourLabel.text = [CTAppLanguage localizedStringForKey:@"fllow_favourLabel_title" withValue:nil withTable:@"Language"];
        favNumber-=1;
        if (favNumber > 9999)
        {
            favCountLabel.text = [NSString stringWithFormat:@"%dW",favNumber/10000];
        }
        if (favNumber <= 0)
        {
            favCountLabel.text = @"0";
        }
        if (favNumber>0 && favNumber <= 9999)
        {
            favCountLabel.text = [NSString stringWithFormat:@"%d",favNumber];
        }
        favBool = NO;
    }
    else
    {
        [favourBtn setBackgroundImage:[UIImage imageNamed:@"dianzan_ok"] forState:UIControlStateNormal];
        favourLabel.text = [CTAppLanguage localizedStringForKey:@"fllow_favoruLabel_title1" withValue:nil withTable:@"Language"];
        favNumber+=1;
        if (favNumber > 9999)
        {
            favCountLabel.text = [NSString stringWithFormat:@"%dW",favNumber/10000];
        }
        if (favNumber <= 0)
        {
            favCountLabel.text = @"0";
        }
        if (favNumber>0 && favNumber <= 9999)
        {
            favCountLabel.text = [NSString stringWithFormat:@"%d",favNumber];
        }
        favBool = YES;
    }
    if ([self.delegate respondsToSelector:@selector(userPublishTableCellHitFavourBtnAction:withBool:)])
    {
        [self.delegate userPublishTableCellHitFavourBtnAction:self withBool:favBool];
    }

}
//评论
- (void)commentBtnAction:(UIButton *) sender
{
    if ([self.delegate respondsToSelector:@selector(userPublishTableCellHitCommentBtnaction:withID:)])
    {
        [self.delegate userPublishTableCellHitCommentBtnaction:self withID:nil];
    }
}
//分享
- (void)shareBtnAction:(UIButton *) sender
{
    if ([self.delegate respondsToSelector:@selector(userPublishTableCellHitShareBtnAction:withID:)])
    {
        [self.delegate userPublishTableCellHitShareBtnAction:self withID:nil];
    }

}
//更多
- (void)moreBtnAction:(UIButton *) sender
{
    if ([self.delegate respondsToSelector:@selector(userPublishTableCellHitMoreBtnAction:withID:)])
    {
        [self.delegate userPublishTableCellHitMoreBtnAction:self withID:nil];
    }
}
//点击点赞头像
- (void)imageViewBtnAction:(UIButton *) sender
{
    //需要一个返回值
    if ([self.delegate respondsToSelector:@selector(userPublishTableCellHitFavBtnHeadAction:withItem:)])
    {
        [self.delegate userPublishTableCellHitFavBtnHeadAction:self withItem:[favArray objectAtIndex:sender.tag-1000]];
    }
}
//点击关注按钮
- (void)attentionBtnAction:(UIButton *) sender
{
//    if (self.delegate respondsToSelector:@selector(attentionbtna)) {
//        <#statements#>
//    }
}

#pragma mark -setter- 
//认证
- (void)setSqcView:(BOOL)sqcBool
{
    if (sqcLabel)
    {
        sqcImageView.hidden = NO;
        sqcLabel.hidden = NO;
    }
    else
    {
        sqcLabel.hidden = YES;
        sqcLabel.hidden = YES;
    }
}

//点赞按钮
- (void)setFavour:(BOOL)favourBool
{
    favBool = favourBool;
    if (favBool)
    {
        [favourBtn setBackgroundImage:[UIImage imageNamed:@"dianzan_ok"] forState:UIControlStateNormal];
        favourLabel.text = [CTAppLanguage localizedStringForKey:@"fllow_favoruLabel_title1" withValue:nil withTable:@"Language"];
    }
    else
    {
        [favourBtn setBackgroundImage:[UIImage imageNamed:@"dianzan"] forState:UIControlStateNormal];
        favourLabel.text = [CTAppLanguage localizedStringForKey:@"fllow_favoruLabel_title" withValue:nil withTable:@"Language"];
    }
}

//名字
- (void)setName:(NSString *) name
{
    nameLabel.text = name;
}
//描述
- (void)setDescribeText:(NSString *)describeText
{
    describeLabel.text = describeText;
}

//富文本
- (void)setDesRange:(NSRange)desRange
{
    NSMutableAttributedString *AttributedStr = [[NSMutableAttributedString alloc]initWithString:describeLabel.text];
    
    [AttributedStr addAttribute:NSFontAttributeName
     
                          value:[UIFont systemFontOfSize:15.0]
     
                          range:desRange];
    //    [AttributedStr addAttribute:NSLinkAttributeName value:@"www.baidu.com" range:desRange];
    [AttributedStr addAttribute:NSForegroundColorAttributeName
     
                          value:[UIColor colorWithRed:255/255.0 green:134/255.0 blue:49/255.0 alpha:1.0]
     //    从第N个起 的几个字
                          range:desRange];
    
    describeLabel.attributedText = AttributedStr;
}

//点赞总数
- (void)setFavourCountLabelText:(int )favCounNumber
{
    favNumber = favCounNumber;
    if (favNumber > 9999)
    {
        favCountLabel.text = [NSString stringWithFormat:@"%dW",favCounNumber/10000];
    }
    if (favNumber <= 0)
    {
        favCountLabel.text = @"0";
    }
    if (favNumber>0 && favNumber <= 9999)
    {
        favCountLabel.text = [NSString stringWithFormat:@"%d",favCounNumber];
    }
    
}

//头像
-(void)setHeadImgUrl:(NSString *)imgUrl
{
    [CTRequestUtil requestImgWithUrl:imgUrl withCompletionSuccessHandler:^(UIImage *img) {
         [headerImageView setBackgroundImage:img forState:UIControlStateNormal];
    } withFailedHandler:^(NSError *error) {
        
    }];
}
//性别
- (void)setSexImgUrl:(NSString *)sexImgStr
{
    sexImageView.image = [UIImage imageNamed:@"female"];
    sexImageView.image = [UIImage imageNamed:@"male"];
}
//大图
- (void)setPicImgUrl:(NSString *)picImgUrl
{
    [CTRequestUtil requestImgWithUrl:picImgUrl withCompletionSuccessHandler:^(UIImage *img) {
        [picImageView setBackgroundImage:img forState:UIControlStateNormal];
    } withFailedHandler:^(NSError *error) {
        
    }];
}
//点赞头像
- (void)setFavHeadImgUrl:(NSArray *)favHeadImgUrl
{
    favArray = [NSMutableArray arrayWithArray:favHeadImgUrl];
    
    [self createFavHeadImageView:favArray];
}
//是否显示关注按钮
- (void)setAttentionBtnBool:(BOOL)attentionBool
{
    UILabel *attentionLabel = [[UILabel alloc]initWithFrame:CGRectMake(CT_HEADER_SCREEN_WIDTH-60, 25, 50, 13)];
    attentionLabel.font = [UIFont systemFontOfSize:13.0];
    attentionLabel.textAlignment = NSTextAlignmentCenter;
    [self addSubview:attentionLabel];
    UIButton *attentionBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    attentionBtn.frame = CGRectMake(CT_HEADER_SCREEN_WIDTH-60, 20, 50, 23);
    [attentionBtn addTarget:self action:@selector(attentionBtnAction:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:attentionBtn];
    if (attentionBool == YES)
    {
        [attentionBtn setBackgroundImage:[UIImage imageNamed:@"bt_bg_yiguanzhu"] forState:UIControlStateNormal];
        attentionLabel.text = [CTAppLanguage localizedStringForKey:@"fllow_attentioned_title" withValue:nil withTable:@"Language"];
        attentionLabel.textColor = timeLabel.textColor;
    }
    if (attentionBool == NO)
    {
        [attentionBtn setBackgroundImage:[UIImage imageNamed:@"bt_bg_guanzhu"] forState:UIControlStateNormal];
        attentionLabel.text =[CTAppLanguage localizedStringForKey:@"fllow_attention_title" withValue:nil withTable:@"Language"];
        attentionLabel.textColor = CT_HEADER_ORANGE_COLOR;
    }
}






@end



@implementation FavHeadBtn


-(void)creatBtn
{
    
}


-(void)setImgUrl:(NSString *)imgUrl
{
    [CTRequestUtil requestImgWithUrl:imgUrl withCompletionSuccessHandler:^(UIImage *img) {
       [self setBackgroundImage:img forState:UIControlStateNormal];
    } withFailedHandler:^(NSError *error) {
        
    }];
}



@end
